package com.tsj.mvp.demo7;


import android.os.Handler;
import android.os.Looper;
import android.util.Log;

/**
 * 专门负责数据层，数据库操作，网络操作，文件操作
 * */
public class LoginModel7 {

    private Handler handler=new Handler(Looper.getMainLooper());//主线程handler一步处理
    public LoginModel7(){

    }
    public void login(String username, String password, CallBack callback){
        Log.w("Activity","login model -------");
        //模拟网络数据请求
        handler.postDelayed(new Runnable() {
            @Override
            public void run() {

                if(username.equals("123456")&&password.equals("123456")){
                    Log.w("Activity","handler -------登录成功");
                    callback.callback("登录成功");
                }else{
                    callback.callback("登录失败");
                }
            }
        },2000);
    }

    interface CallBack{
        void callback(String result);
    }
}
